function Tipanimate() {
	$('#bottom_tip').animate({ 'height': '40px' }, 200);
	$('#bottom_tip').delay(1000).animate({ 'height': '0px' }, 200, function() { $('#bottom_tip').html('');
		onoff = false; });
}
function getQuery(name) {
	var url = location.search;
	var reg = new Object();
	if(url.indexOf('?') != -1) {
		var str = url.substr(1);
		var strs = str.split('&');
		for(var i = 0; i < strs.length; i++) {
			reg[strs[i].split('=')[0]] = unescape(strs[i].split('=')[1]);
		}
	}
	return reg;
}
var headimgurl = getQuery('headimgurl').headimgurl;

////if(code) {
//
//	$.ajax({
//		type:"POST",
//		url:"http://testmedia.heardtech.com/Post/WechatRegister",
//		data:{
//			wechatcode:code
//		},
//		success:function(data){
//			if(data.code==000000){
//
//			}else{
//				alert(data.message)
//			}
//		}
//	});
	$('.wxhead').prop('src',headimgurl);
	//注册
	var onoff = false;
	$('#getNum').click(function() {
		var inp = $('.phone').val();
		if(onoff) { return false };
		onoff = true;
		if(inp == '') {
			$('#bottom_tip').html('请填写手机号码');
			Tipanimate();
		} else if(!(/^1(2|3|4|5|6|7|8|9)\d{9}$/.test(inp))) {
			$('#bottom_tip').html('请填写正确手机号码');
			Tipanimate();
		} else {
			$.ajax({
				type: "POST",
				url: apiCollect.apiGetVerification,
				data: {
					username: inp
				},
				success: function(data) {
					if(data.code == "000000") {
						var i = 61;
						var timer = setInterval(function() {
							i--;
							$('#getNum').html(i + 's');
							if(i == 0) {
								$('#getNum').html('获取短信验证码');
								clearInterval(timer);
							}
						}, 1000);
						onoff = false;
					} else {
						$('#bottom_tip').html(data.message);
						Tipanimate();
					}
				}
			});
		}

	});
//下一步点击
$('#bottom_middle').click(function(){
	// var wid =getQuery('wid').wid;
	var wid = localStorage.getItem('wid') ? localStorage.getItem('wid') : 0;
	var inp = $('.phone').val();
	var num = $('#num').val();
	var sev = $('.severs').val();
	if(inp ==''){
		$('#bottom_tip').html('请输入手机号码');
		Tipanimate();
	}else if(!(/^1(2|3|4|5|6|7|8|9)\d{9}$/.test(inp))){
		$('#bottom_tip').html('请输入正确手机号码');
		Tipanimate();
	}else if(num ==''){
		$('#bottom_tip').html('请输入验证码');
		Tipanimate();
	}else if(sev == ''){
		$('#bottom_tip').html('请填写密码');
		Tipanimate();
	}else{
		console.log(wid)
		$.ajax({
			type:"POST",
			url: apiCollect.apiRegister,
			data:{
				username:inp,
				code:num,
				password:sev,
				wid:wid
			},
			success:function(data){
				if(data.code=='000000'){
					window.location.href='regesitorMain.html';
				}else{
					$('#bottom_tip').html(data.message);
				  	Tipanimate()
				}
			}
		});
	}
})



$(document).on('keydown', function (ev) {
	if (ev.keyCode == 13) {
		$('#bottom_middle').trigger('click');
	}
})

// $('#logo_info').click(function () {
// 	window.location.href = '/';
// })